home *** CD-ROM | disk | FTP | other *** search
/ MPEG Toolkit / MPEG Toolkit.iso / win / med-lib / mdctrl.z / MDSAMP.BAS < prev    next >
Encoding:
BASIC Source File  |  1995-07-10  |  4.5 KB  |  160 lines

  1. Option Explicit
  2.  
  3. Global ngFileHandle%     ' Handle to AV file
  4.  
  5. ' Button Indexes
  6. Global Const CTRL_OPEN = 0
  7. Global Const CTRL_PLAY = 1
  8. Global Const CTRL_PAUSE = 2
  9. Global Const CTRL_STOP = 3
  10. Global Const CTRL_CLOSE = 4
  11.  
  12.  
  13. Global Const VOL_MAX = 100
  14. Global Const VOL_NORM = 30
  15. Global Const VOL_MULT = 10
  16.  
  17. Global Const SPEED_MAX = 200
  18. Global Const SPEED_NORM = 100
  19. Global Const SPEED_MULT = 10
  20.  
  21. Global Const SET_SIZE = 0
  22. Global Const SET_CLIP = 1
  23.  
  24. Global Const INFO_FRAME = 0
  25. Global Const INFO_STATE = 1
  26. Global Const INFO_LENGTH = 2
  27. Global Const INFO_RATE = 3
  28. Global Const INFO_TIME = 4
  29. Global Const INFO_COLOR_RED = 5
  30. Global Const INFO_COLOR_GREEN = 6
  31. Global Const INFO_COLOR_BLUE = 7
  32.  
  33.  
  34. Global Const STATE_CLOSED = "Closed"
  35. Global Const STATE_PAUSED = "Paused"
  36. Global Const STATE_PLAYING = "Playing"
  37. Global Const STATE_END = "End"
  38. Global Const STATE_STOPPED = "Stopped"
  39.  
  40. Global Const STATE_VAL_CLOSED = 0
  41. Global Const STATE_VAL_PLAYING = 1
  42. Global Const STATE_VAL_PAUSED = 3
  43. Global Const STATE_VAL_END = 4
  44. Global Const STATE_VAL_STOPPED = 5
  45.  
  46. Function nFuncOpenMedia% (ByVal hwnd%, ByVal szFileName$, ByVal nWidth%, ByVal nHeight%, ByVal lBegFrame&, ByVal lEndFrame&)
  47.  
  48.     Dim nTmpWidth%, nTmpHeight%
  49.     Dim nXPos%, nYPos%
  50.     Dim nHandle%
  51.     
  52.     ' This is done to control the number of open files in this sample
  53.     ' application to 1.  It is not done because of a limitation of
  54.     ' the mdCtrl Software.
  55.     If ngFileHandle Then ngFileHandle = mdClose(ngFileHandle)
  56.  
  57.     If frmMDSample.chkAutoSize Then ' Setup for autosize
  58.         
  59.         nTmpWidth = MD_VIDSIZE_W_AUTOMATIC
  60.         nTmpHeight = MD_VIDSIZE_H_AUTOMATIC
  61.     
  62.     Else  ' Validate user values   FRAME_DEFAULT_BEG
  63.         
  64.         nTmpWidth = nWidth
  65.         nTmpHeight = nHeight
  66.  
  67.         If nWidth = 0 Then
  68.             nTmpWidth = MD_VIDSIZE_W_AUTOMATIC
  69.         ElseIf nWidth < 7 Then
  70.             nTmpHeight = MD_VIDSIZE_H_AUTOMATIC
  71.         End If
  72.     
  73.         If nHeight = MD_VIDSIZE_H_AUTOMATIC And nWidth > 6 Then
  74.             nTmpWidth = MD_VIDSIZE_W_AUTOMATIC
  75.         End If
  76.     
  77.     End If
  78.  
  79.     sbrUpdateStatus "Opening the file: " & szFileName
  80.     ' Open the file but don't show it immediately
  81.     ' so that I can position it.  This is done since
  82.     ' I don't know the size yet.
  83.     nHandle = mdOpen(hwnd, szFileName, 0, 0, nTmpWidth, nTmpHeight, lBegFrame, lEndFrame, MD_CONTROL_INT_NONMODAL, MD_LOAD_AV_HIDDEN)
  84.  
  85.     If nHandle Then
  86.         sbrUpdateStatus "Open Successful, Sizing and Positioning"
  87.  
  88.         ' Let the file tell me the width and height
  89.         mdGetWinSize nHandle, nTmpWidth, nTmpHeight
  90.         
  91.         ' Calculate the X,Y position
  92.         nXPos = Int(((frmMDSample.Width / 15) - nTmpWidth) / 2)
  93.         nYPos = Int((240 - nTmpHeight) / 2)
  94.  
  95.         mdSetWinPos nHandle, nXPos, nYPos ' Put the window
  96.         
  97.         If frmMDSample.chkVisible Then   ' Show it?
  98.             If frmMDSample.chkControlBar Then  ' Show all
  99.                 mdShow nHandle
  100.             Else
  101.                 mdShowVideo nHandle   ' Show just the video window
  102.             End If
  103.         End If
  104.  
  105.         sbrUpdateStatus "Open Successful"
  106.  
  107.     Else
  108.         
  109.         sbrUpdateStatus "Open Unsuccessful"
  110.     
  111.     End If
  112.  
  113.     nFuncOpenMedia = nHandle  ' Return the handle
  114.  
  115. End Function
  116.  
  117. Sub sbrOpenFile (szFileName$)
  118.     
  119.     sbrUpdateStatus "File Search"
  120.     '....Following code created by CMDialog Thing
  121.     frmMDSample.dlgFileOpen.CancelError = True
  122.     frmMDSample.dlgFileOpen.DefaultExt = ""
  123.     frmMDSample.dlgFileOpen.DialogTitle = "Select Audio/Video File"
  124.     frmMDSample.dlgFileOpen.Filename = ""
  125.     frmMDSample.dlgFileOpen.FilterIndex = 0
  126.     frmMDSample.dlgFileOpen.Filter = "AVI Files (*.avi)|*.avi|AVS Files (*.avs)|*.avs|MPEG Files (*.mpg)|*.mpg|Wave Files (*.wav)|*.wav"
  127.     frmMDSample.dlgFileOpen.HelpCommand = 0
  128.     frmMDSample.dlgFileOpen.HelpContext = 0
  129.     frmMDSample.dlgFileOpen.HelpFile = ""
  130.     frmMDSample.dlgFileOpen.HelpKey = ""
  131.     frmMDSample.dlgFileOpen.InitDir = ""
  132.     frmMDSample.dlgFileOpen.MaxFileSize = 256
  133.     frmMDSample.dlgFileOpen.Flags = OFN_OVERWRITEPROMPT Or OFN_PATHMUSTEXIST
  134.     
  135.     On Error GoTo DialogError
  136.  
  137.     frmMDSample.dlgFileOpen.Action = 1
  138.  
  139.     szFileName = frmMDSample.dlgFileOpen.Filename
  140.  
  141.     sbrUpdateStatus "File Found...Click The Open Button To Open The File"
  142.  
  143.     Exit Sub
  144.  
  145. DialogError:
  146.     
  147.     sbrUpdateStatus "File Search Cancelled"
  148.  
  149.     Exit Sub
  150.  
  151.  
  152. End Sub
  153.  
  154. Sub sbrUpdateStatus (ByVal szStatus$)
  155.  
  156.     frmMDSample.pnlStatus = szStatus
  157.  
  158. End Sub
  159.  
  160.